package tfmcbs.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

import tfmcbs.TfmcbsPackage;
import tfmcbs.diagram.edit.parts.ArtifactName2EditPart;
import tfmcbs.diagram.edit.parts.ArtifactNameEditPart;
import tfmcbs.diagram.edit.parts.ArtifactStereotype2EditPart;
import tfmcbs.diagram.edit.parts.ArtifactStereotypeEditPart;
import tfmcbs.diagram.edit.parts.CompositeComponentName2EditPart;
import tfmcbs.diagram.edit.parts.CompositeComponentNameEditPart;
import tfmcbs.diagram.edit.parts.CompositeComponentStereotype2EditPart;
import tfmcbs.diagram.edit.parts.CompositeComponentStereotypeEditPart;
import tfmcbs.diagram.edit.parts.ConnectionNameEditPart;
import tfmcbs.diagram.edit.parts.DependencyNameEditPart;
import tfmcbs.diagram.edit.parts.DependencyStereotypeEditPart;
import tfmcbs.diagram.edit.parts.InterfaceName2EditPart;
import tfmcbs.diagram.edit.parts.InterfaceNameEditPart;
import tfmcbs.diagram.edit.parts.PortRealizationNameEditPart;
import tfmcbs.diagram.edit.parts.PortUsageNameEditPart;
import tfmcbs.diagram.edit.parts.PrimitiveComponentName2EditPart;
import tfmcbs.diagram.edit.parts.PrimitiveComponentNameEditPart;
import tfmcbs.diagram.edit.parts.PrimitiveComponentStereotype2EditPart;
import tfmcbs.diagram.edit.parts.PrimitiveComponentStereotypeEditPart;
import tfmcbs.diagram.edit.parts.PrimitiveRealizationNameEditPart;
import tfmcbs.diagram.edit.parts.PrimitiveUsageNameEditPart;
import tfmcbs.diagram.edit.parts.ProvidingPortNameEditPart;
import tfmcbs.diagram.edit.parts.RequiringPortNameEditPart;
import tfmcbs.diagram.parsers.MessageFormatParser;
import tfmcbs.diagram.part.ComponentBasedSystemVisualIDRegistry;

/**
 * @generated
 */
public class ComponentBasedSystemParserProvider extends AbstractProvider
		implements IParserProvider {

	/**
	 * @generated
	 */
	private IParser primitiveComponentName_5066Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveComponentName_5066Parser() {
		if (primitiveComponentName_5066Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			primitiveComponentName_5066Parser = parser;
		}
		return primitiveComponentName_5066Parser;
	}

	/**
	 * @generated
	 */
	private IParser primitiveComponentStereotype_5067Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveComponentStereotype_5067Parser() {
		if (primitiveComponentStereotype_5067Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getComponent_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			primitiveComponentStereotype_5067Parser = parser;
		}
		return primitiveComponentStereotype_5067Parser;
	}

	/**
	 * @generated
	 */
	private IParser compositeComponentName_5075Parser;

	/**
	 * @generated
	 */
	private IParser getCompositeComponentName_5075Parser() {
		if (compositeComponentName_5075Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			compositeComponentName_5075Parser = parser;
		}
		return compositeComponentName_5075Parser;
	}

	/**
	 * @generated
	 */
	private IParser compositeComponentStereotype_5076Parser;

	/**
	 * @generated
	 */
	private IParser getCompositeComponentStereotype_5076Parser() {
		if (compositeComponentStereotype_5076Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getComponent_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			compositeComponentStereotype_5076Parser = parser;
		}
		return compositeComponentStereotype_5076Parser;
	}

	/**
	 * @generated
	 */
	private IParser interfaceName_5077Parser;

	/**
	 * @generated
	 */
	private IParser getInterfaceName_5077Parser() {
		if (interfaceName_5077Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			interfaceName_5077Parser = parser;
		}
		return interfaceName_5077Parser;
	}

	/**
	 * @generated
	 */
	private IParser artifactName_5078Parser;

	/**
	 * @generated
	 */
	private IParser getArtifactName_5078Parser() {
		if (artifactName_5078Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			artifactName_5078Parser = parser;
		}
		return artifactName_5078Parser;
	}

	/**
	 * @generated
	 */
	private IParser artifactStereotype_5079Parser;

	/**
	 * @generated
	 */
	private IParser getArtifactStereotype_5079Parser() {
		if (artifactStereotype_5079Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getArtifact_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			artifactStereotype_5079Parser = parser;
		}
		return artifactStereotype_5079Parser;
	}

	/**
	 * @generated
	 */
	private IParser primitiveComponentName_5068Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveComponentName_5068Parser() {
		if (primitiveComponentName_5068Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			primitiveComponentName_5068Parser = parser;
		}
		return primitiveComponentName_5068Parser;
	}

	/**
	 * @generated
	 */
	private IParser primitiveComponentStereotype_5069Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveComponentStereotype_5069Parser() {
		if (primitiveComponentStereotype_5069Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getComponent_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			primitiveComponentStereotype_5069Parser = parser;
		}
		return primitiveComponentStereotype_5069Parser;
	}

	/**
	 * @generated
	 */
	private IParser compositeComponentName_5073Parser;

	/**
	 * @generated
	 */
	private IParser getCompositeComponentName_5073Parser() {
		if (compositeComponentName_5073Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			compositeComponentName_5073Parser = parser;
		}
		return compositeComponentName_5073Parser;
	}

	/**
	 * @generated
	 */
	private IParser compositeComponentStereotype_5074Parser;

	/**
	 * @generated
	 */
	private IParser getCompositeComponentStereotype_5074Parser() {
		if (compositeComponentStereotype_5074Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getComponent_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			compositeComponentStereotype_5074Parser = parser;
		}
		return compositeComponentStereotype_5074Parser;
	}

	/**
	 * @generated
	 */
	private IParser interfaceName_5070Parser;

	/**
	 * @generated
	 */
	private IParser getInterfaceName_5070Parser() {
		if (interfaceName_5070Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			interfaceName_5070Parser = parser;
		}
		return interfaceName_5070Parser;
	}

	/**
	 * @generated
	 */
	private IParser artifactName_5071Parser;

	/**
	 * @generated
	 */
	private IParser getArtifactName_5071Parser() {
		if (artifactName_5071Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			artifactName_5071Parser = parser;
		}
		return artifactName_5071Parser;
	}

	/**
	 * @generated
	 */
	private IParser artifactStereotype_5072Parser;

	/**
	 * @generated
	 */
	private IParser getArtifactStereotype_5072Parser() {
		if (artifactStereotype_5072Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getArtifact_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			artifactStereotype_5072Parser = parser;
		}
		return artifactStereotype_5072Parser;
	}

	/**
	 * @generated
	 */
	private IParser providingPortName_5051Parser;

	/**
	 * @generated
	 */
	private IParser getProvidingPortName_5051Parser() {
		if (providingPortName_5051Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getPort_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			providingPortName_5051Parser = parser;
		}
		return providingPortName_5051Parser;
	}

	/**
	 * @generated
	 */
	private IParser requiringPortName_5053Parser;

	/**
	 * @generated
	 */
	private IParser getRequiringPortName_5053Parser() {
		if (requiringPortName_5053Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getPort_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			requiringPortName_5053Parser = parser;
		}
		return requiringPortName_5053Parser;
	}

	/**
	 * @generated
	 */
	private IParser connectionName_6017Parser;

	/**
	 * @generated
	 */
	private IParser getConnectionName_6017Parser() {
		if (connectionName_6017Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			connectionName_6017Parser = parser;
		}
		return connectionName_6017Parser;
	}

	/**
	 * @generated
	 */
	private IParser dependencyName_6018Parser;

	/**
	 * @generated
	 */
	private IParser getDependencyName_6018Parser() {
		if (dependencyName_6018Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			dependencyName_6018Parser = parser;
		}
		return dependencyName_6018Parser;
	}

	/**
	 * @generated
	 */
	private IParser dependencyStereotype_6019Parser;

	/**
	 * @generated
	 */
	private IParser getDependencyStereotype_6019Parser() {
		if (dependencyStereotype_6019Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getDependency_Stereotype() };
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
			parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
			dependencyStereotype_6019Parser = parser;
		}
		return dependencyStereotype_6019Parser;
	}

	/**
	 * @generated
	 */
	private IParser primitiveUsageName_6030Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveUsageName_6030Parser() {
		if (primitiveUsageName_6030Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			primitiveUsageName_6030Parser = parser;
		}
		return primitiveUsageName_6030Parser;
	}

	/**
	 * @generated
	 */
	private IParser portUsageName_6022Parser;

	/**
	 * @generated
	 */
	private IParser getPortUsageName_6022Parser() {
		if (portUsageName_6022Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			portUsageName_6022Parser = parser;
		}
		return portUsageName_6022Parser;
	}

	/**
	 * @generated
	 */
	private IParser primitiveRealizationName_6023Parser;

	/**
	 * @generated
	 */
	private IParser getPrimitiveRealizationName_6023Parser() {
		if (primitiveRealizationName_6023Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			primitiveRealizationName_6023Parser = parser;
		}
		return primitiveRealizationName_6023Parser;
	}

	/**
	 * @generated
	 */
	private IParser portRealizationName_6024Parser;

	/**
	 * @generated
	 */
	private IParser getPortRealizationName_6024Parser() {
		if (portRealizationName_6024Parser == null) {
			EAttribute[] features = new EAttribute[] { TfmcbsPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			portRealizationName_6024Parser = parser;
		}
		return portRealizationName_6024Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case PrimitiveComponentNameEditPart.VISUAL_ID:
			return getPrimitiveComponentName_5066Parser();
		case PrimitiveComponentStereotypeEditPart.VISUAL_ID:
			return getPrimitiveComponentStereotype_5067Parser();
		case CompositeComponentNameEditPart.VISUAL_ID:
			return getCompositeComponentName_5075Parser();
		case CompositeComponentStereotypeEditPart.VISUAL_ID:
			return getCompositeComponentStereotype_5076Parser();
		case InterfaceNameEditPart.VISUAL_ID:
			return getInterfaceName_5077Parser();
		case ArtifactNameEditPart.VISUAL_ID:
			return getArtifactName_5078Parser();
		case ArtifactStereotypeEditPart.VISUAL_ID:
			return getArtifactStereotype_5079Parser();
		case PrimitiveComponentName2EditPart.VISUAL_ID:
			return getPrimitiveComponentName_5068Parser();
		case PrimitiveComponentStereotype2EditPart.VISUAL_ID:
			return getPrimitiveComponentStereotype_5069Parser();
		case CompositeComponentName2EditPart.VISUAL_ID:
			return getCompositeComponentName_5073Parser();
		case CompositeComponentStereotype2EditPart.VISUAL_ID:
			return getCompositeComponentStereotype_5074Parser();
		case InterfaceName2EditPart.VISUAL_ID:
			return getInterfaceName_5070Parser();
		case ArtifactName2EditPart.VISUAL_ID:
			return getArtifactName_5071Parser();
		case ArtifactStereotype2EditPart.VISUAL_ID:
			return getArtifactStereotype_5072Parser();
		case ProvidingPortNameEditPart.VISUAL_ID:
			return getProvidingPortName_5051Parser();
		case RequiringPortNameEditPart.VISUAL_ID:
			return getRequiringPortName_5053Parser();
		case ConnectionNameEditPart.VISUAL_ID:
			return getConnectionName_6017Parser();
		case DependencyNameEditPart.VISUAL_ID:
			return getDependencyName_6018Parser();
		case DependencyStereotypeEditPart.VISUAL_ID:
			return getDependencyStereotype_6019Parser();
		case PrimitiveUsageNameEditPart.VISUAL_ID:
			return getPrimitiveUsageName_6030Parser();
		case PortUsageNameEditPart.VISUAL_ID:
			return getPortUsageName_6022Parser();
		case PrimitiveRealizationNameEditPart.VISUAL_ID:
			return getPrimitiveRealizationName_6023Parser();
		case PortRealizationNameEditPart.VISUAL_ID:
			return getPortRealizationName_6024Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(ComponentBasedSystemVisualIDRegistry
					.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(ComponentBasedSystemVisualIDRegistry
					.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (ComponentBasedSystemElementTypes.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
